export function useColumn() {
  const { auth } = useAuth();
  const showRoleColumnWH = () => {
    return auth([
      'e-workingHours-edit',
    ]);
  };
  const showRoleColumnD = () => {
    return auth([
      'e-details-edit',
    ]);
  };
  const allColumnsD: any = [
    {
      title: '单位',
      dataIndex: 'company',
      key: 'company',
      align: 'center',
      fixed: 'left',
      width: '20%',
    },
    {
      title: '人员编码',
      dataIndex: 'personnelCode',
      key: 'personnelCode',
      align: 'center',
      width: '150px',
    },
    {
      title: '姓名',
      dataIndex: 'name',
      key: 'name',
      align: 'center',
      width: '100px',
    },
    {
      title: '研发通用认证级别',
      dataIndex: 'rdCommonLevel',
      key: 'rdCommonLevel',
      align: 'center',
      width: '160px',
    },
    {
      title: '研发专业认证级别',
      dataIndex: 'rdProfessionLevel',
      key: 'rdProfessionLevel',
      align: 'center',
      width: '160px',
    },
    {
      title: '研发经验级别',
      dataIndex: 'rdExperienceLevel',
      key: 'rdExperienceLevel',
      align: 'center',
      width: '160px',
    },
    {
      title: '研发工程师认证级别',
      dataIndex: 'engineerLevel',
      key: 'engineerLevel',
      align: 'center',
      width: '160px',
    },
    {
      title: '总工时',
      dataIndex: 'hours',
      key: 'hours',
      align: 'center',
      width: '100px',
    },
    {
      title: '操作',
      dataIndex: 'operation',
      key: 'lastColumn',
      align: 'center',
      fixed: 'right',
    },
  ];
  const allColumnsWH: any = [
    {
      title: '工时月份',
      dataIndex: 'workMonth',
      align: 'center',
      width: '10%',
      key: 'workmonth',
    },
    {
      title: '成员姓名',
      dataIndex: 'employeeName',
      align: 'center',
      width: '25%',
      key: 'employeename',
    },
    {
      title: '成员ID',
      dataIndex: 'employeeId',
      align: 'center',
      width: '25%',
      key: 'employeeid',
    },
    {
      title: '复核工时',
      dataIndex: 'reviewedHours',
      align: 'center',
      width: '20%',
      key: 'reviewedhours',
      customRender: ({ record }: { record: any }) => {
        return record.reviewedhours || record.REVIEWEDHOURS;
      },
    },
    {
      title: '操作',
      dataIndex: 'operation',
      key: 'lastColumn',
      width: '20%',
      align: 'center',
    },
  ];
  const columnsD: any = computed(() => {
    return allColumnsD.filter((column: any) => {
      const flag = showRoleColumnD();
      if (!flag && column.title === '操作') {
        return false;
      }
      return true;
    });
  });
  const columnsWH: any = computed(() => {
    return allColumnsWH.filter((column: any) => {
      const flag = showRoleColumnWH();
      if (!flag && column.title === '操作') {
        return false;
      }
      return true;
    });
  });
  return {
    columnsWH,
    columnsD,
  };
}
